/**
 * ViewController.m
 *
 * The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License");
 * you may not use this file except in compliance with the License. You may obtain a copy of the License 
 * at http://www.mozilla.org/MPL/
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND,
 * either express or implied. See the License for the specific language governing rights and limitations 
 * under the License.
 *
 * The Original Code is gcast-toolbox4iphone.
 *
 * The Initial Developers of the Original Code is Giannandrea Castaldi.
 */

#import "GTActivityNotifierExampleViewController.h"
#import "GTActivityNotifier.h"
#import "NotificationCases.h"
#import "UITableView+GTExtension.h"

@interface GTActivityNotifierExampleViewController ()
@property(nonatomic,retain) UITableView *tableView;
@property(nonatomic,retain) id currentNotification;
@end

@implementation GTActivityNotifierExampleViewController
@synthesize tableView, currentNotification;

- (void)loadView {
  self.view = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
  self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  self.tableView = [[[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped] autorelease];
  self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  self.tableView.delegate = self;
  self.tableView.dataSource = self;
  [self.view addSubview:self.tableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
  return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  UITableViewCell *cell = nil;
  switch (indexPath.row) {
    case 0:
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"One Message Case"] autorelease];
      cell.textLabel.text = @"One Message Case";
      break;
    case 1:
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Two Messages Case"] autorelease];
      cell.textLabel.text = @"Two Messages Case";
      break;
    case 2:
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Three Messages Case"] autorelease];
      cell.textLabel.text = @"Three Messages Case";
      break;
    case 3:
      cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Three Messages And Confirm Case"] autorelease];
      cell.textLabel.text = @"Three Messages And Confirm Case";
      break;
  }
  return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  [self.tableView deselectCurrentRow];
  switch (indexPath.row) {
    case 0:
      self.currentNotification = [OneMessageNotificationCase notificationCase];
      break;
    case 1:
      self.currentNotification = [TwoMessagesNotificationCase notificationCase];
      break;
    case 2:
      self.currentNotification = [ThreeMessagesNotificationCase notificationCase];
      break;
    case 3:
      self.currentNotification = [ThreeMessagesAndConfirmNotificationCase notificationCase];
      break;
  }
}

@end
